Reduce boot-time memory fragmentation
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 15 Mar 2010 13:24:33 +0000 (13:24 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 15 Mar 2010 13:24:33 +0000 (13:24 +0000)
commit4280d3ee4cb16ef462172e1da5dc3a1ff5719782
treef7085fc34da4192c5d8c5b8b6b0ac8670f8e1e64
parentd8f3a67bf98789a2f760d01f6af0d5afb824ae7e
Reduce boot-time memory fragmentation

On certain NUMA configurations having init_node_heap() consume the
first few pages of a new node's memory for internal data structures
leads to unnecessary memory fragmentation, which can - with
sufficiently many nodes - result in there not remaining enough memory
below 4G for Dom0 to set up its swiotlb and PCI-consistent buffers.

Since alloc_boot_pages() generally consumes from the end of available
regions, make init_node_heap() prefer the end of such regions too (so
that fragmentation occurs at only one end of a region).

(Adjustment from first version: Use the tail of the region when the
end addresses alignment is less or equal to the beginning one's, not
just when it's less.)

Further, in order to prefer allocations from higher memory locations,
insert memory regions in reverse order in end_boot_allocator(), with
the exception of inserting one region residing on the boot CPU's node
first (for the statically allocated structures - used for the first
node seen - to be used for this node).

Finally, reduce MAX_ORDER on x86 to the maximum useful value (1Gb), so
that the reservation of a page on node boundaries (again leading to
fragmentation) can be avoided as much as possible (having node
boundaries on less the 1Gb aligned addresses is expected to be rare,
if found in practice at all).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
xen/common/page_alloc.c
xen/include/asm-x86/config.h